$(function () {

    var eid = GetQueryString("eid");
    var wjId = GetQueryString("wjId");
    var sel = $.Params.create();
    sel.ajax("get", getAdminIP() + "qdWjQuestions/" + eid, function (data) {
        if (data.success) {
            var val = data.result;
            $("#title").val(val.title);
            $("#type").val(val.type);
            $("#code").val(val.code);

        } else {
            alert(data.msg);
        }
    })
    $("#addData").on("click", function () {
        var title = $("#title").val();
        var type = $("#type").val();
        var code = $("#code").val();
        if (title == "") {
            alert("问题标题不能为空！");
            return false;
        }
        var addSel = $.Params.create();
        addSel.addParams("title", title);
        addSel.addParams("type", type);
        addSel.addParams("code", code);
        addSel.ajax("put", getAdminIP() + "qdWjQuestions/" + eid, function (data) {
            if (data.success) {
                window.location.href = "qdWjQuestionList.html?wjId=" + wjId;
            } else {
                alert(data.msg);
            }
        })
    })


    $("#cancelAdd").on("click", function () {
        history.go(-1);
    })
})